###############################################
#
#Compute the neighbors productivity excluding the work with 
#i and discounting the work between the neighbors
#IMPORTANT: 
# -DATA NEED TO BE SET BEFORE RUNNING THE FUNCTION
#- NAME THIS DATA SET AS "y"
#
################################################

netprod<-function(indi,g,y){

  #Dropping the articles published by author i - if author i works 
  a3 <- subset(y, auth1!=indi & auth2!=indi & auth3!=indi) 

  #Obtaining the articles data for each neighbor of order 1#
  nei1 <- V(g)[nei(indi)]
  lnei1 <- sapply(nei1, function(v) list(subset(a3,
                           auth2==v|auth1==v|auth3==v)) )
  authm<-as.data.frame(do.call("rbind",lnei1))
  authmu<-unique(authm)
  netprod<-sum(authmu$prod) #Dropping duplicates

  netprod
}



